package lvm.fonctions.eval;

import java.util.HashMap;

import lvm.Contexte;
import lvm.LvmException;
import lvm.fonctions.Fonctions;
import lvm.struct.Scons;
import lvm.struct.Sexpr;
import lvm.struct.Symbole;
import lvm.view.ContextesVariablesView;
import lvm.view.runIhm;

/**
 * Class en cour d'implémentation
 * @author vsplit
 *
 */
public class Expr implements Fonctions {
	
	Contexte contexteLocale = new Contexte();
	
	public Expr(String val,Sexpr args,Sexpr fonction){
		loadArgs(args);
		System.out.println(args);
		//ContextesVariablesView dd = new ContextesVariablesView("qsd", contexteLocale, runIhm.window.getDisplay());
		System.out.println(contexteLocale);
	}

	public Sexpr exec(Sexpr sexpr){
		//System.out.println("XD"+sexpr.toString());
		return null;
	}
	
	
	public void loadArgs(Sexpr args){
		System.out.println(args);
		Symbole cache;
		Sexpr value;
		if(args instanceof Symbole){
			try{
				setArg(args.toString(),args.eval());
			}catch (LvmException e) {
				setArg(args.toString(),new Symbole(""));
			}
		}else{
			try{
				this.loadArgs(args.eval());
			}catch (LvmException e) {
				setArg(args.toString(),new Symbole(""));
			}
		}
		
	}
	public void setArg(String s,Sexpr arg){
		contexteLocale.putVariable(s,arg);
	}
	
	
	@Override
	public String toString() {
		return "expr : "+super.toString();
	}
	
	@Override
	public Sexpr eval() throws LvmException {
		return null;
	}

	@Override
	public Sexpr getCar() throws LvmException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Sexpr getCdr() throws LvmException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean equals(Sexpr arg) throws LvmException {
		// TODO Auto-generated method stub
		return false;
	}
}
